import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import {getQueryString} from '../utils/util';
import { Button } from 'antd-mobile';
import LxrItem from '../components/lxrItem';

import 'antd-mobile/lib/button/style/index.css';
import '../static/styles/lxr.css';

import { get } from '../api/getData';

class Lxr extends Component {
    constructor(props) {
        super(props);
        this.state = {
            hasChildren:-1,
            mzsm: false,
            lxr:[]
        }
    }

    componentDidMount() {
        document.title = '联系人';
        let __this = this;
        get('/api/activity/lxr', {}, function(error, data){
            if(error === null){
                __this.setState({
                    lxr:data.data.list
                });
            }
        });
    }

    redirectAdd(){
        window.location.href = '/lxr/add?redirect=lxr/list';
    }

    render() {
        return (<div>
            <div className='p22'>
                {
                    this.state.lxr.map(function(item, index){
                        return <LxrItem show='gx' data={item} edit={true} key={index}/>
                    })
                }
                <Button onClick={() => this.redirectAdd()} className='enroll-button mt40'>添加</Button>
            </div>
        </div>);
    }
}

export default Lxr;
